package com.edu.exam.entity.examination.paper;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.time.LocalDateTime;

/**
 * 监考员可用时间实体类
 * 所属模块：E-01 考试执行模块
 * 对应数据库表：invigilator_availability
 *
 * <p>监考员可用时间实体，记录监考员每周的可用时间段。
 * 支持精确的时间冲突检测和监考员可用性判断。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "invigilator_availability")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InvigilatorAvailability {

    /**
     * 可用时间ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 监考员ID
     */
    @Column(name = "invigilator_id", nullable = false)
    private Long invigilatorId;

    /**
     * 星期几 (1-7, 1=周一)
     */
    @Column(name = "day_of_week", nullable = false)
    private Integer dayOfWeek;

    /**
     * 开始时间
     */
    @Column(name = "start_time", nullable = false)
    private LocalTime startTime;

    /**
     * 结束时间
     */
    @Column(name = "end_time", nullable = false)
    private LocalTime endTime;

    /**
     * 状态
     */
    @Column(name = "status", length = 20, nullable = false)
    private String status;

    /**
     * 备注
     */
    @Column(name = "remarks", length = 200)
    private String remarks;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 监考员关联
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "invigilator_id", insertable = false, updatable = false)
    private Invigilator invigilator;
}